<?php

	/**
	 * TransferenciaHistorico
	 * @author benrainir
	 * Classe para gerenciar a entidade TransferenciaHistorico
	 */
    class TransferenciaHistorico extends BaseModel
    {
    	protected $transferenciahistoricoid ;
		protected $transferenciaid;
		protected $dataregistro ;
		protected $observacao ;
		protected $statusid ;
		protected $operadorid;    	

        const tablename = "transferenciahistorico";
        const tablekey = "transferenciahistoricoid";
        const tablesequence = "transferenciahistorico_transferenciahistoricoid_seq";
        
        /**
         * retorna o historico mais recente
         * @return CarenciaHistorico
         */
        public function getHistoricoAtual($transferenciaid){
        	if ($transferenciaid != null) {
        		$result = $this->listar(array('where'=>'transferenciaid = '.$transferenciaid,'orderBy'=>'dataregistro DESC LIMIT 1','order'=>''));
	        	$obj = pg_fetch_object($result);
	        	return new TransferenciaHistorico($obj->transferenciahistoricoid);
        	}
        	else{
        		return new TransferenciaHistorico();
        	}
        }
        
        /**
         * @return Status
         */
        public function getStatus(){
        	return new Status($this->statusid);
        }
        
    }
?>